<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>配置管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/web/res/css/xadmin.css">
    <script src="/web/res/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/web/res/js/xadmin.js"></script>
    <script type="text/javascript"  src="/web/res/kindeditor4110/kindeditor-min.js" charset="utf-8"></script>
</head>

<body style="background-color: white;">

    <div class="layui-fluid" id="orderEdit">

        <form class="layui-form layui-form-pane" id="formsubmit" action="/btpeizhi/save">
            <input type="hidden" value="1" name="id" id="id"/>
            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                <legend class="form-title">配置管理</legend>
            </fieldset>
            <div class="layui-form-item">

                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                    <legend class="form-title">通讯录删除时间（小时）</legend>
                </fieldset>

                <div class="layui-form-item">
                    <label class="layui-form-label">删除时间</label>
                    <div class="layui-input-inline">
                        <input type="text"  placeholder="0" name="tongxunlutime" required lay-verify="required|number" value="${(peiZhi.tongxunlutime?c)!''}" autocomplete="off" class="layui-input"/>
                    </div>
                </div>

                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                    <legend class="form-title">大转盘金额</legend>
                </fieldset>

                <div class="layui-form-item">
                    <label class="layui-form-label">抽奖金额</label>
                    <div class="layui-input-inline">
                        <input type="text"  placeholder="0" name="choujiangmoney" required lay-verify="required|number" value="${(peiZhi.choujiangmoney?c)!''}" autocomplete="off" class="layui-input"/>
                    </div>
                </div>

                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                    <legend class="form-title">常用配置管理</legend>
                </fieldset>

                <div class="layui-form-item">
                    <label class="layui-form-label">客服联系方式</label>
                    <div class="layui-input-block">
                        <input type="text"  placeholder="0" name="guanfangkefu" required lay-verify="required" value="${(peiZhi.guanfangkefu)!''}" autocomplete="off" class="layui-input"/>
                    </div>
                </div>

                <!--
                <div class="layui-form-item">
                    <label class="layui-form-label">收款码配置</label>
                    <div class="layui-input-block">
                        <textarea  class="layui-textarea" id="shoukuanma" name="shoukuanma" style="height:350px;width: 658px">${(peiZhi.shoukuanma)!''}</textarea>
                    </div>
                </div>-->


                <div class="layui-form-item">
                    <label class="layui-form-label">游戏规则</label>
                    <div class="layui-input-block">
                        <textarea  class="layui-textarea" id="youxiguize" name="youxiguize" style="height:350px;width: 658px">${(peiZhi.youxiguize)!''}</textarea>
                    </div>
                </div>

                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                    <legend class="form-title">APP配置</legend>
                </fieldset>

                <div class="layui-form-item">
                    <label class="layui-form-label">APP介绍</label>
                    <div class="layui-input-block">
                        <textarea  class="layui-textarea" id="appjieshao" name="appjieshao" style="height:350px;width: 658px">${(peiZhi.appjieshao)!''}</textarea>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">APP公告</label>
                    <div class="layui-input-block">
                        <textarea  class="layui-textarea" id="gonggao" name="gonggao" style="height:350px;width: 658px">${(peiZhi.gonggao)!''}</textarea>
                    </div>
                </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="button" class="layui-btn layui-btn-radius" lay-submit lay-filter="save" >&emsp;保存&emsp;</button>
                </div>
            </div>

        </form>

    </div>

    <script>
        KindEditor.ready(function(K) {
            var editor1 = K.create('textarea[id="shoukuanma"]', {
                cssPath : '/web/res/kindeditor4110/plugins/code/prettify.css',
                uploadJson : '/btpeizhi/fileUploadpeizhi',
                fieldName : 'imgFile',
                allowImageRemote : false,
                items : ['source', '|','justifyleft', '|','justifycenter', '|','justifyright', '|','justifyfull', '|','fontname', '|','fontsize', '|','forecolor', '|','hilitecolor', '|','bold', '|','italic', '|','underline', '|','strikethrough', '|','removeformat','|','image'],
                afterBlur: function () {this.sync(); }//******这一步非常重要，如果遗漏，则后台无法接收到数据。
            });
            var editor2 = K.create('textarea[id="youxiguize"]', {
                cssPath : '/web/res/kindeditor4110/plugins/code/prettify.css',
                uploadJson : '/btpeizhi/fileUploadpeizhi',
                fieldName : 'imgFile',
                allowImageRemote : false,
                items : ['source', '|','justifyleft', '|','justifycenter', '|','justifyright', '|','justifyfull', '|','fontname', '|','fontsize', '|','forecolor', '|','hilitecolor', '|','bold', '|','italic', '|','underline', '|','strikethrough', '|','removeformat','|','image'],
                afterBlur: function () {this.sync(); }//******这一步非常重要，如果遗漏，则后台无法接收到数据。
            });

            var editor3 = K.create('textarea[id="appjieshao"]', {
                cssPath : '/web/res/kindeditor4110/plugins/code/prettify.css',
                uploadJson : '/btpeizhi/fileUploadpeizhi',
                fieldName : 'imgFile',
                allowImageRemote : false,
                items : ['source', '|','justifyleft', '|','justifycenter', '|','justifyright', '|','justifyfull', '|','fontname', '|','fontsize', '|','forecolor', '|','hilitecolor', '|','bold', '|','italic', '|','underline', '|','strikethrough', '|','removeformat','|','image'],
                afterBlur: function () {this.sync(); }//******这一步非常重要，如果遗漏，则后台无法接收到数据。
            });



            var editor5 = K.create('textarea[id="gonggao"]', {
                cssPath : '/web/res/kindeditor4110/plugins/code/prettify.css',
                uploadJson : '/btpeizhi/fileUploadpeizhi',
                fieldName : 'imgFile',
                allowImageRemote : false,
                items : ['source', '|','justifyleft', '|','justifycenter', '|','justifyright', '|','justifyfull', '|','fontname', '|','fontsize', '|','forecolor', '|','hilitecolor', '|','bold', '|','italic', '|','underline', '|','strikethrough', '|','removeformat','|','image'],
                afterBlur: function () {this.sync(); }//******这一步非常重要，如果遗漏，则后台无法接收到数据。
            });


            prettyPrint();
        });
    </script>

    <script>


        layui.use(['laydate', 'form', 'upload'], function () {
            let $ = layui.$;
            var laydate = layui.laydate;
            var form = layui.form;
            var upload = layui.upload;
            form.render();

            $(".img_big").click(function(){
                var url = $(this).attr('title');
                $("#displayImg").attr("src", url);
                var height = $("#displayImg").height();
                var width = $("#displayImg").width();
                layer.open({
                    type: 1,
                    title: false,
                    closeBtn: 1,//隐藏关闭按钮
                    shade: [0.3, '#000'],//黑色背景（0.3代表颜色深度）
                    shadeClose: true,//点击遮罩关闭大图
                    area: [width + 'px', height + 'px'], //宽高
                    resize:false,//不可拖拽缩放
                    content: "<img alt=" + name + " title=" + name + " src=" + url + " height=500px; width=500px;" + "/>"
                });
            });

            $.fn.extend({
                serializeObject: function() {
                    var obj = {}; //声明一个对象
                    $.each(this.serializeArray(), function(index, field) {
                        obj[field.name] = field.value; //通过变量，将属性值，属性一起放到对象中
                    })
                    return obj;
                }
            });


            // 重新添加删除功能
            $('.upload-cancel').on('click', (event) => {
                let self = $(event.currentTarget);
            self.parent().remove();
            event.stopPropagation();

            if($("input[id='imgpathhide']").length<1){
                $('#uploadtemplate').show();
            }else{
                $('#uploadtemplate').hide();
            }
        });


            upload.render({
                elem: '#uploadtemplate',
                auto: false,
                accept: 'images',
                acceptMime: 'image/*',
                choose: function (obj) {
                    obj.preview(function (index, file, result) {
                        $('#uploadlist').prepend('<div class="upload-imgBox">  <input type="hidden"  id="imgpathhide" value="'+result+'"  class="layui-input"/><div class="upload-cancel" id="'+index+'">x</div><img  src="' + result + '" alt="' + file.name +
                            '" class="upload-select-img"></div>');
                        $(".upload-cancel").on("click",function(e){
                            $(this).parent().remove();
                            if($("input[id='imgpathhide']").length<1){
                                $('#uploadtemplate').show();
                            }
                        })
                        if($("input[id='imgpathhide']").length>=1){
                            $('#uploadtemplate').hide();
                        }
                        // alert($("input[id='imgpathhide']").length);
                    });
                },
                done: function (res) {
                }
            });



            form.on('submit('+$("button[lay-submit]:eq(0)").attr("lay-filter")+')', function(data){
                $("input[id='imgpathhide']").each(function(index,ele){
                    // $(this).attr("name","imgList["+index+"]");
                    $(this).attr("name","vippic");
                });


                layer.confirm('确认要保存吗？', function (index) {
                    ajaxPost($,$("#formsubmit").attr("action"),$("#formsubmit").serializeObject(),function (data) {
                        if (data.code == 0) {
                            layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                                setTimeout('window.location.reload()',1000);
                            });
                        } else {
                            layer.msg(data.msg, {icon: 2, time: 3000}, function(){
                            });
                        }
                    });
                });
            });
        });
    </script>
</body>

</html>